﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs"
    Inherits="CRM.WEB.Users.ChangePassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>修改密码</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="../Static/demo.css" rel="stylesheet" type="text/css" />
    <script src="../Static/boot.js" type="text/javascript"></script>
    <link href="../Static/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="form1" style="padding-left: 11px; padding-bottom: 5px;">
        <table style="table-layout: fixed;">
            <tr>
                <td style="width: 90px;">
                    原始密码：
                </td>
                <td style="width: 150px;">
                    <input id="txt_OldPwd" class="mini-password" required="true" />
                </td>
            </tr>
            <tr>
                <td style="width: 90px;">
                    密码：
                </td>
                <td style="width: 150px;">
                    <input id="txt_Pwd" class="mini-password" required="true" vtype="minLength:6;maxLength:20"
                        minlengtherrortext="密码不能少于6个字符" value="" requirederrortext="确认密码不能为空" />
                </td>
            </tr>
            <tr>
                <td>
                    确认密码：
                </td>
                <td>
                    <input id="txt_confirmPwd" class="mini-password" required="true" vtype="minLength:6;maxLength:20"
                        minlengtherrortext="密码不能少于6个字符" value="" onvalidation="psdCheck" requirederrortext="确认密码不能为空" />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <a class="mini-button" iconcls="icon-save" onclick="ChangePassword()">确定</a>
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        mini.parse();

        var form = new mini.Form("form1");

        // 重新输入密码验证
        function repsdCheck(e) {
            var password = mini.get("txt_Pwd").getValue();
            var repassword = mini.get("txt_confirmPwd").getValue();
            psdCheck(e);
            if (e.isValid) {
                if ($.trim(password) != $.trim(repassword)) {
                    e.errorText = "输入的两次密码不一致";
                    e.isValid = false;
                }
            }
        }

        // 密码验证
        function psdCheck(e) {
            if (e.isValid) {
                var password = mini.get("txt_Pwd").getValue();
                var repassword = mini.get("txt_confirmPwd").getValue();
                if (repassword != password) {
                    e.errorText = "输入的两次密码不一致";
                    e.isValid = false;
                }
            }
        }


        function ChangePassword() {
            var o = form.getData();
            form.validate();
            if (form.isValid() == false)
                return;
            var oldPassword = mini.get("#txt_OldPwd").getValue();
            var password = mini.get("#txt_Pwd").getValue(); //密码

            $.ajax({
                url: "../Ajax/AjaxService.aspx?method=ChangePassword",
                type: 'post',
                data: {
                    oldPassword:oldPassword,
                    password: password
                },
                cache: false,
                success: function (text) {
                    var result = $.parseJSON(text);
                    if (result.res == "操作成功") {
                        mini.alert("操作成功!");
                    }
                    else {
                        mini.alert(result.error);
                        //mini.alert("操作失败!");
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }
    </script>
</body>
</html>
